package com.yami.shop.api.controller;

import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.otherservice.UserLevelUpgradeService;
import com.yami.shop.security.api.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 消息提醒
 */
@RestController
@RequestMapping("/p/messageRemind")
public class MessageRemindController {
    @Autowired
    private UserLevelUpgradeService userLevelUpgradeService;

    /**
     * 小程序打开首页,弹出消息提醒
     * @return
     */
    @GetMapping("/getMessage")
    public ServerResponseEntity<List<Map<String,Object>>> getMessage() {
        String userId = SecurityUtils.getUser().getUserId();
        List<Map<String,Object>> list=new ArrayList<>();

        //查询会员超期提醒
        Map<String, Object> map = userLevelUpgradeService.expireDateRemind(userId);
        if(map != null){
            Map<String,Object> map1=new HashMap<>();
            map1.put("type","userLevelExpireDate");
            map1.put("data",map);
            list.add(map1);
        }

        return ServerResponseEntity.success(list);
    }
}
